package com.example.quartzdemo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.quartzdemo.entity.TaskLog;
import com.example.quartzdemo.service.TaskLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/api/tasks")
public class TaskLogController {
    @Autowired
    private TaskLogService taskLogService;

    @GetMapping("/taskLogs")
    public IPage<TaskLog> taskLog(@RequestParam("taskId") String taskId,
                                  @RequestParam(value = "page",defaultValue = "1") Integer page,
                                  @RequestParam(value = "size",defaultValue = "10") Integer size,
                                  @RequestParam(value = "startTime",required = false)
                                 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
                                 LocalDateTime startTime,
                                  @RequestParam(value = "endTime",required = false)
                                 @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
                                 LocalDateTime endTime,
                                  @RequestParam(value = "status",required = false) String status) {
       return taskLogService.taskLogs(taskId, page, size,startTime,endTime,status);
    }
}
